package com.alibaba.cloud.application.mapping;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
public interface CommonProtoMapping {
    default Date map(LocalDateTime localDateTime) {
        ZoneId zoneId = ZoneId.systemDefault();
        ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
        return Date.from(zonedDateTime.toInstant());
    }

    default Date map(ZonedDateTime zonedDateTime) {
        return Date.from(zonedDateTime.toInstant());
    }

    default LocalDateTime map(Date date) {
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
    }

    default ZonedDateTime map1(Date date) {
        LocalDateTime localDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
        return ZonedDateTime.from(localDateTime);
    }
}
